package com.treeste;

import java.util.Comparator;

public class Student implements Comparable<Student> {
    private String name;
    private int yuwen;
    private int shuxue;
    private int yinyu;

    public Student(String xiaopang, int i) {
    }

    public Student(String name, int yuwen, int shuxue, int yinyu) {
        this.name = name;
        this.yuwen = yuwen;
        this.shuxue = shuxue;
        this.yinyu = yinyu;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getYuwen() {
        return yuwen;
    }

    public void setYuwen(int yuwen) {
        this.yuwen = yuwen;
    }

    public int getShuxue() {
        return shuxue;
    }

    public void setShuxue(int shuxue) {
        this.shuxue = shuxue;
    }

    public int getYinyu() {
        return yinyu;
    }

    public void setYinyu(int yinyu) {
        this.yinyu = yinyu;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", yuwen=" + yuwen +
                ", shuxue=" + shuxue +
                ", yinyu=" + yinyu +
                '}';
    }

    public int geiage() {
        int a = yuwen + shuxue + yinyu;
        return a;
    }


    @Override
    public int compareTo(Student o) {
        int c = this.geiage() - o.geiage();
        c = c == 0 ? this.yuwen - o.yuwen : c;
        c = c == 0 ? this.shuxue - o.shuxue : c;
        c = c == 0 ? this.yinyu - o.yinyu : c;
        c = c == 0 ? this.name.compareTo(o.name) : c;
        return 0;
    }
}
